package com.bwie.controller;

import com.bwie.pojo.TbBrand;
import com.bwie.service.TbBrandService;
import com.bwie.utils.Result;
import com.bwie.vo.PageInfoVo;
import com.sun.org.apache.regexp.internal.RE;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/shop/brand")
public class BrandController {
    @Autowired
    TbBrandService tbBrandService;


    /**
     * 分页获取品牌列表
     *
     * @param pageInfoVo
     * @return
     */
    @PostMapping("/getBrandList")
    private Result getBrandList(@RequestBody PageInfoVo pageInfoVo) {
        return tbBrandService.getBrandList(pageInfoVo);
    }

    /**
     * 添加品牌
     *
     * @param tbBrand
     * @return
     */
    @PostMapping("/addBrand")
    public Result addBrand(@RequestBody @Validated TbBrand tbBrand) {
        return tbBrandService.addBrand(tbBrand);
    }

    /**
     * 修改品牌状态
     *
     * @return
     */
    @PostMapping("/updateBrandStatus")
    public Result updateBrandStatus(@RequestBody TbBrand tbBrand) {
        return tbBrandService.updateBrandStatus(tbBrand);
    }

    /**
     * 删除
     *
     * @param brandId
     * @return
     */
    @PostMapping("/brandDelete/{brandId}")
    public Result brandDelete(@PathVariable("brandId") Integer brandId) {
        return tbBrandService.brandDelete(brandId);
    }

    /**
     * 批量删除
     *
     * @param brandList
     * @return
     */
    @PostMapping("/batchDeleteBrand")
    public Result batchDeleteBrand(@RequestBody List<TbBrand> brandList) {
        return tbBrandService.batchDeleteBrand(brandList);
    }

    /**
     * 下拉框查询
     * @return
     */
    @PostMapping("/getBrandAll")
    public Result getBrandAll() {
        return tbBrandService.getBrandAll();
    }
}
